/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.bar.carta.model.impl;

import com.bar.carta.model.Plato;
import com.bar.carta.model.PlatoModel;
import com.bar.carta.model.PlatoSoap;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the Plato service. Represents a row in the &quot;carta_Plato&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.bar.carta.model.PlatoModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PlatoImpl}.
 * </p>
 *
 * @author pgonzalm
 * @see PlatoImpl
 * @see com.bar.carta.model.Plato
 * @see com.bar.carta.model.PlatoModel
 * @generated
 */
@JSON(strict = true)
public class PlatoModelImpl extends BaseModelImpl<Plato> implements PlatoModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a plato model instance should use the {@link com.bar.carta.model.Plato} interface instead.
	 */
	public static final String TABLE_NAME = "carta_Plato";
	public static final Object[][] TABLE_COLUMNS = {
			{ "platoId", Types.BIGINT },
			{ "tipoId", Types.BIGINT },
			{ "createDate", Types.TIMESTAMP },
			{ "activo", Types.BOOLEAN },
			{ "imagen", Types.BIGINT },
			{ "precio", Types.FLOAT }
		};
	public static final String TABLE_SQL_CREATE = "create table carta_Plato (platoId LONG not null primary key,tipoId LONG,createDate DATE null,activo BOOLEAN,imagen LONG,precio DOUBLE)";
	public static final String TABLE_SQL_DROP = "drop table carta_Plato";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.bar.carta.model.Plato"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.bar.carta.model.Plato"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static Plato toModel(PlatoSoap soapModel) {
		Plato model = new PlatoImpl();

		model.setPlatoId(soapModel.getPlatoId());
		model.setTipoId(soapModel.getTipoId());
		model.setCreateDate(soapModel.getCreateDate());
		model.setActivo(soapModel.getActivo());
		model.setImagen(soapModel.getImagen());
		model.setPrecio(soapModel.getPrecio());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<Plato> toModels(PlatoSoap[] soapModels) {
		List<Plato> models = new ArrayList<Plato>(soapModels.length);

		for (PlatoSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.bar.carta.model.Plato"));

	public PlatoModelImpl() {
	}

	public long getPrimaryKey() {
		return _platoId;
	}

	public void setPrimaryKey(long primaryKey) {
		setPlatoId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_platoId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return Plato.class;
	}

	public String getModelClassName() {
		return Plato.class.getName();
	}

	@JSON
	public long getPlatoId() {
		return _platoId;
	}

	public void setPlatoId(long platoId) {
		_platoId = platoId;
	}

	@JSON
	public long getTipoId() {
		return _tipoId;
	}

	public void setTipoId(long tipoId) {
		_tipoId = tipoId;
	}

	@JSON
	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	@JSON
	public boolean getActivo() {
		return _activo;
	}

	public boolean isActivo() {
		return _activo;
	}

	public void setActivo(boolean activo) {
		_activo = activo;
	}

	@JSON
	public long getImagen() {
		return _imagen;
	}

	public void setImagen(long imagen) {
		_imagen = imagen;
	}

	@JSON
	public float getPrecio() {
		return _precio;
	}

	public void setPrecio(float precio) {
		_precio = precio;
	}

	@Override
	public Plato toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (Plato)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					Plato.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		PlatoImpl platoImpl = new PlatoImpl();

		platoImpl.setPlatoId(getPlatoId());
		platoImpl.setTipoId(getTipoId());
		platoImpl.setCreateDate(getCreateDate());
		platoImpl.setActivo(getActivo());
		platoImpl.setImagen(getImagen());
		platoImpl.setPrecio(getPrecio());

		platoImpl.resetOriginalValues();

		return platoImpl;
	}

	public int compareTo(Plato plato) {
		long primaryKey = plato.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Plato plato = null;

		try {
			plato = (Plato)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = plato.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<Plato> toCacheModel() {
		PlatoCacheModel platoCacheModel = new PlatoCacheModel();

		platoCacheModel.platoId = getPlatoId();

		platoCacheModel.tipoId = getTipoId();

		Date createDate = getCreateDate();

		if (createDate != null) {
			platoCacheModel.createDate = createDate.getTime();
		}
		else {
			platoCacheModel.createDate = Long.MIN_VALUE;
		}

		platoCacheModel.activo = getActivo();

		platoCacheModel.imagen = getImagen();

		platoCacheModel.precio = getPrecio();

		return platoCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{platoId=");
		sb.append(getPlatoId());
		sb.append(", tipoId=");
		sb.append(getTipoId());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", activo=");
		sb.append(getActivo());
		sb.append(", imagen=");
		sb.append(getImagen());
		sb.append(", precio=");
		sb.append(getPrecio());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("com.bar.carta.model.Plato");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>platoId</column-name><column-value><![CDATA[");
		sb.append(getPlatoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tipoId</column-name><column-value><![CDATA[");
		sb.append(getTipoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>activo</column-name><column-value><![CDATA[");
		sb.append(getActivo());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>imagen</column-name><column-value><![CDATA[");
		sb.append(getImagen());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>precio</column-name><column-value><![CDATA[");
		sb.append(getPrecio());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = Plato.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			Plato.class
		};
	private long _platoId;
	private long _tipoId;
	private Date _createDate;
	private boolean _activo;
	private long _imagen;
	private float _precio;
	private transient ExpandoBridge _expandoBridge;
	private Plato _escapedModelProxy;
}